﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Authentication.Data.DataContextStorage
{
    public class DataContextFactory
    {
        /// <summary>
        ///     The get data context.
        /// </summary>
        /// <returns>
        ///     The <see cref="AuthenticationEntities" />.
        /// </returns>
        public static DbContext GetDataContext()
        {
            IDataContextStorageContainer _dataContextStorageContainer = DataContextStorageFactory.CreateStorageContainer();
            DbContext libraryDataContext = _dataContextStorageContainer.GetDataContext();

            if (libraryDataContext == null)
            {
                libraryDataContext = new AuthenticationEntities();
                _dataContextStorageContainer.Store(libraryDataContext);
            }

            return libraryDataContext;
        }
    }
}
